﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Windows.Forms;
namespace DSTIFIMTR01
{
    /// <summary>
    /// MainWindow.xaml 的交互逻辑
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
            this.Loaded += MainWindow_Loaded;
        }

        void MainWindow_Loaded(object sender, RoutedEventArgs e)
        {
            /*
             Dim comm As MaBuComm.comm
    Set comm = New MaBuComm.comm
    comm.wait = 500
    comm.CommPort = 1
    comm.Settings = ""
    Dim rcs As ReadCounterSpeed
    Set rcs = New ReadCounterSpeed
    Set comm.CollectImpl = rcs
        */
        }
        private void btnGetCount_Click(object sender, RoutedEventArgs e)
        {
            MabuCommAPI.comm();
        }

        private void btnSne2Itnex_Click_1(object sender, RoutedEventArgs e)
        {
            
            IntPtr hwnd_win ;          // 存放实例1中的Form1窗口的窗口句柄    
            IntPtr hwnd_button ;     // 存放实例1中的Form1中的button1控件的窗口句柄       // 参数1：窗口类型，参数2：窗口名称     
            hwnd_win = MabuCommAPI.FindWindow("itcscw5", "QI03"); // 得到Form1窗口的句柄。         
            // 参数1：父窗口句柄，   参数2：子窗口指针；参数3：窗口类型；参数4：窗口文本   
            hwnd_button = MabuCommAPI.FindWindowEx(hwnd_win, new IntPtr(0), "itcscw5", "BRUTLG");       
            // 定义待发送的消息     
            string s= "2222BRUTLG.QI03=1,23";
            const int WM_SETTEXT = 0x000C;
            MabuCommAPI.SendMessage(hwnd_win, WM_SETTEXT, IntPtr.Zero, s);
            MabuCommAPI.SendMessage(hwnd_button, WM_SETTEXT, IntPtr.Zero, s);
            // 向Form1窗口的button1控件发送BM_CLICK消息     
            //MabuCommAPI.PostMessage(msg.HWnd, msg.Msg, msg.WParam, msg.LParam);
        }  
    }
}
